<?php

/** @var \Laravel\Lumen\Routing\Router $router */

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/


use Keepa\API\Request;

$router->get('/', function () use ($router) {
    $api = new \Keepa\KeepaAPI(env('KEEPA_API_KEY'));
    $r = Request::getProductRequest((int)3, null, null,null,0,0, ['B09TBK3YV6'], ['stats' => 180, 'rating' => 1]);
    $response = $api->sendRequestWithRetry($r);
    dd($response);
});

//Vben-admin后台接口
$router->group(['namespace' => 'Admin', 'prefix' => 'admin-api'],function () use ($router){

    $router->post('register', 'HomeController@register');
    $router->post('login', 'HomeController@login');

    //需要登录
    $router->group(['middleware' => 'user'], function () use ($router) {

        //用户
        $router->get('getUserInfo', 'UserController@getUserInfo');
        $router->get('getPermCode', 'UserController@getPermCode');
        $router->get('getMenuList', 'UserController@getMenuList');
        $router->get('logout', 'UserController@logout');
        $router->get('system/getAccountList', 'UserController@getAccountList');
        $router->get('system/getAllRoleList', 'UserController@getAllRoleList');
        $router->post('system/accountExist', 'UserController@accountExist');
        $router->post('system/createOrUpdateAccount', 'UserController@createOrUpdateAccount');
        $router->post('system/setAdminStatus', 'UserController@setAdminStatus');

        //角色
        $router->get('system/getRoleListByPage', 'RoleController@getRoleList');
        $router->post('system/setRoleStatus', 'RoleController@setRoleStatus');
        $router->post('system/createOrUpdateRole', 'RoleController@createOrUpdateRole');
        $router->delete('system/deleteRole', 'RoleController@deleteRole');

        //菜单
        $router->get('system/getMenuList', 'PermissionController@getAllMenu');
        $router->post('system/createOrUpdateMenu', 'PermissionController@createOrUpdateMenu');
        $router->delete('system/deleteMenu', 'PermissionController@deleteMenu');

        //amazon分类
        $router->post('category/getCategoryInfo', 'CategoryController@getCategoryInfo');

    });
});

//客户端请求亚马逊信息接口
$router->group(['namespace' => 'Api', 'prefix' => 'api'],function () use ($router){
    $router->post('category/info', 'HomeController@categories');
    $router->post('category/product', 'HomeController@products');
    $router->post('product/info', 'HomeController@product_info');
    $router->post('task/product', 'HomeController@task_product');
});
